home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / C / Libraries / stdwin / Packs / vt / vtputs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-10-18  |  1.3 KB  |  62 lines  |  [TEXT/????]

  1. /* A simple output function, emulating a "dumb tty" */
  2.  
  3. #include "vtimpl.h"
  4.  
  5. void
  6. vtputs(vt, text)
  7.     register VT *vt;
  8.     register char *text;
  9. {
  10. #ifndef NDEBUG
  11.     if (text == NULL)
  12.         vtpanic("vtputs with NULL text");
  13. #endif
  14.     while (*text != EOS) {
  15.         if (PRINTABLE(*text)) {
  16.             register char *end = text;
  17.             do {
  18.                 text++;
  19.             } while (PRINTABLE(*text));
  20.             vtputstring(vt, text, (int) (end-text));
  21.             text = end;
  22.         }
  23.         else switch (*text++) {
  24.         
  25.         case BEL:    /* Make some noise */
  26.             wfleep();
  27.             break;
  28.         
  29.         case BS:    /* Move 1 left */
  30.             /* Rely on vtsetcursor's clipping */
  31.             vtsetcursor(vt, vt->cur_row, vt->cur_col - 1);
  32.             /* Don't erase --
  33.                that's part of intelligent echoing */
  34.             break;
  35.         
  36.         case TAB:    /* Move to next tab stop */
  37.             /* Rely on vtsetcursor's clipping */
  38.             vtsetcursor(vt, vt->cur_row,
  39.                 (vt->cur_col & ~7) + 8);
  40.             /* Normalize cursor (may cause scroll!) */
  41.             vtputstring(vt, "", 0);
  42.             break;
  43.         
  44.         case LF:    /* Move cursor down in same column */
  45.             vtsetcursor(vt, vt->cur_row + 1, vt->cur_col);
  46.             /* Normalize cursor (may cause scroll!) */
  47.             vtputstring(vt, "", 0);
  48.             break;
  49.         
  50.         case FF:    /* Start over */
  51.             vtreset(vt);
  52.             break;
  53.         
  54.         case CR:    /* Back to col 0 on same line */
  55.             vtsetcursor(vt, vt->cur_row, 0);
  56.             break;
  57.         
  58.         }
  59.     }
  60.     vtsync(vt);
  61. }
  62.